package com.jinduplan.planmanager.mvp.presenter

import com.cxz.kotlin.baselibs.ext.ss
import com.cxz.kotlin.baselibs.mvp.BasePresenter
import com.jinduplan.planmanager.mvp.contract.ClockinRecordContract
import com.jinduplan.planmanager.mvp.model.ClockinRecordModel

class ClockinRecordPresenter:BasePresenter<ClockinRecordContract.Model,ClockinRecordContract.View>(),ClockinRecordContract.Presenter {

    override fun createModel(): ClockinRecordContract.Model = ClockinRecordModel()

    override fun refreshClockinRecord(page: String, limit: String) {
        mModel?.refreshClockinRecord(page,limit)?.ss(mModel, mView, onSuccess = {
            if (page.toInt() == 1) {
                mView?.refreshClockinRecordResult(it.data)
            } else {
                mView?.loadClockinRecordResult(it.data)
            }
        },onError = {
            mView?.refreshClockinRecordResult(null)
        })
    }
}